const path = require('path')
const webpack = require('webpack')

function resolve(dir) {
    return path.join(__dirname, dir)
}

module.exports = {



    devServer: {
        proxy: { //配置跨域
            '/ally': {
                //target: 'http://39.98.50.45:8087',
                target: 'http://39.98.50.45:8087',
                changOrigin: true, //允许跨域
                // pathRewrite: {
                //     '^': '/'
                // }
            },
            '/api': {
                //target: 'http://39.98.50.45:8087',
                target: 'http://localhost:3000',
                changOrigin: true, //允许跨域
                // pathRewrite: {
                //     '^': '/'
                // }
            },
        },
    },

    publicPath: './', // 基本路径
    outputDir: 'dist', // 输出文件目录
    assetsDir: "static", //放置生成的静态文件目录（js css img）
    productionSourceMap: false, // 生产环境是否生成 sourceMap 文件

    chainWebpack: config => {
        config.resolve.alias
            .set('@', resolve('src'))
            .set('assets', resolve('src/assets'))
            .set('components', resolve('src/components'))
    },
    configureWebpack: (config) => {
        if (process.env.NODE_ENV === 'production') { // 为生产环境修改配置...
            config.mode = 'production';
            config["performance"] = { //打包文件大小配置
                "maxEntrypointSize": 10000000,
                "maxAssetSize": 30000000
            }
        }
    }
}